﻿//城市，区域选择
///mytype =1表示是选择大的区域，=2表示是后台执行，要选中来的选择的二级区域
function firstSelectChange(target, mytype) {
    var $this = $(target);
    var sid = $this.val();
    if (sid != "0") {
        var url = $this.attr("data-url")+"&id=" + sid + "&t=" + new Date().getTime();
        jQuery.ajax(
        {
            type: "get",
            url: url,
            dataType: "json",
            success: function (msg) {
                parsexml(msg, mytype);
            }
        })
    }
    else {
        document.getElementById("ddljj_subsort").options.length = 0;
        var id = "0";
        var name = "请选择";
        $("#hfjj_sub_id ").val(id)
        $I("ddljj_subsort").options.add(new Option(name, id));
    }
}

function parsexml(smg, mytype) {
    document.getElementById("ddljj_subsort").options.length = 0;
    if (mytype == 1) {
        $("#ddljj_subsort ").val("-1");
    }
    $I("ddljj_subsort").options.add(new Option("请选择", "0"));
    if (typeof (smg) == "object" && typeof (smg.sort) == "object") {
        var length = smg.sort.length;
        for (var i = 0; i < length; i++) {
            var id = smg.sort[i].ID;
            var name = smg.sort[i].classname;
            $I("ddljj_subsort").options.add(new Option(name, id));
           
        }
    }
    //选中
    if (mytype == 2) {
        $("#ddljj_subsort ").val($("#hfjj_sub_id").val() + "");
    }
}

function secondSelectChange(target)
{
    $("#hfjj_sub_id").val($(target).val())
}